﻿@model DLM.Web.ViewModel.NativeSelectionPageView
@using DLM.Domain.DTO;
@using DLM.Services.Implementations;
@{
    var provinces = PageDataService.ShowProvince();

}
<script type="text/javascript">
    $(document).ready(function () {
        $("#ddlNativeProvince").change(function () {
            var province = $("#ddlNativeProvince").find("option:selected").val();
            $.getJSON("/Common/FindCity", { province: province }, function (data) {
                var ddlCity = $("#ddlNativeCity");
                ddlCity.empty();
                ddlCity.append($('<option/>', { value: 0, text: "请选择" }));
                $.each(data, function (index, itemData) {
                    ddlCity.append($('<option/>', {
                        value: itemData.Value,
                        text: itemData.Text
                    }));
                });
            });
        });

        $("#ddlNativeCity").change(function () {
            var city = $("#ddlNativeCity").find("option:selected").val();
            $.getJSON("/Common/FindZone", { city: city }, function (data) {
                var ddlZone = $("#ddlNativeZone");
                ddlZone.empty();
                ddlZone.append($('<option/>', { value: 0, text: "请选择" }));
                $.each(data, function (index, itemData) {
                    ddlZone.append($('<option/>', {
                        value: itemData.Value,
                        text: itemData.Text
                    }));
                });
            });
        });

    });

</script>
<span>省份:</span>
@if (string.IsNullOrEmpty(Model.SelectedNativeProvince))
{
    if (Request.RawUrl.Contains("/User/UserEdit/"))
    {
    @Html.DropDownListFor(x => x.SelectedNativeProvince, new SelectList(provinces, "Value", "Text"), "请选择", new { @class = "select-validation-error", id = "ddlNativeProvince" })

    }
    else
    { 
    @Html.DropDownListFor(x => x.SelectedNativeProvince, new SelectList(provinces, "Value", "Text"), "请选择", new { @class = "sel", id = "ddlNativeProvince" })

    }

}
else
{
    @Html.DropDownListFor(x => x.SelectedNativeProvince, new SelectList(provinces, "Value", "Text"), "请选择", new { @class = "sel", id = "ddlNativeProvince" })
 
}
<span>城市:</span>
@if (string.IsNullOrEmpty(Model.SelectedNativeCity))
{

    if (Request.RawUrl.Contains("/User/UserEdit/"))
    {
      
    @Html.DropDownListFor(x => x.SelectedNativeCity, new SelectList(Enumerable.Empty<SelectListItem>()), "请选择", new { @class = "select-validation-error", id = "ddlNativeCity" })

    }
    else
    { 
    @Html.DropDownListFor(x => x.SelectedNativeCity, new SelectList(Enumerable.Empty<SelectListItem>()), "请选择", new { @class = "sel", id = "ddlNativeCity" })

    }

}
else
{
    var cityList = new List<SelectListItem> 
                        { new SelectListItem { Text = "请选择", Value = "" },
                            new SelectListItem { Text = Model.SelectedNativeCity, Value = Model.SelectedNativeCity, Selected = true }
                           
                        };

    @Html.DropDownListFor(x => x.SelectedNativeCity, cityList, new { @class = "sel", id = "ddlNativeCity" })

}
<span>区:</span>
@if (string.IsNullOrEmpty(Model.SelectedNativeZone))
{
    if (Request.RawUrl.Contains("/User/UserEdit/"))
    {
    @Html.DropDownListFor(x => x.SelectedNativeZone, new SelectList(Enumerable.Empty<SelectListItem>()), "请选择", new { @class = "select-validation-error", id = "ddlNativeZone" })

    }
    else
    { 
    @Html.DropDownListFor(x => x.SelectedNativeZone, new SelectList(Enumerable.Empty<SelectListItem>()), "请选择", new { @class = "sel", id = "ddlNativeZone" })

    }

}
else
{
    var zoneList = new List<SelectListItem> 
                        { new SelectListItem { Text = "请选择", Value = "" },
                            new SelectListItem { Text = Model.SelectedNativeZone, Value = Model.SelectedNativeZone, Selected = true }
                           
                        };
    @Html.DropDownListFor(x => x.SelectedNativeZone, zoneList, new { @class = "sel", id = "ddlNativeZone" })

}
